import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/login',//后端不带项目名的地址
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}
export function getUserInfoByToken(token) {
  return request({
    url: '/personalInfo/getUserInfoByToken',
    method: 'get',
    params: { "token":token }
  })
}
export function tfExistName(userName,token) {
  return request({
    url: '/personalInfo/tfExistName',
    method: 'get',
    params: { "token":token,"userName":userName }
  })
}

export function updatePersonalInfo(data,token) {
  return request({
    url: '/personalInfo/updatePersonalInfo',
    method: 'post',
    params: { token },
    data//json
  })
}
export function getInfoRole(token) {
  return request({
    url: '/user/infoRole',
    method: 'get',
    params: { token }
  })
}

export function tfExistUserName(userName) {
  return request({
    url: '/register/tfExistUserName',
    method: 'get',
    params: { "userName":userName }
  })
}
export function registerUser(data) {
  return request({
    url: '/register/registerUser',
    method: 'post',
    data
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}
//user
export function findByPage(query) {
  return request({
    url: '/user/CRUD/findBy',
    method: 'post',
    params: query //表单数据
  })
}
export function deleteUser(userId) {
  return request({
    url: '/user/CRUD/deleteById',
    method: 'get',
    params: { "userId":userId }//form
  })
}
export function addUser(data) {
  return request({
    url: '/user/CRUD/add',
    method: 'post',
    data//json
  })
}
export function updateUser(data) {
  return request({
    url: '/user/CRUD/update',
    method: 'post',
    data//json
  })
}
